﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
             xmlns:cal="http://www.caliburnproject.org"
             xmlns:ctrl="clr-namespace:MediaOwl.Common.ControlTemplates;assembly=MediaOwl.Common"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
             x:Class="MediaOwl.Views.ModuleView"
             mc:Ignorable="d"
             d:DesignHeight="300"
             d:DesignWidth="400">
    <UserControl.Resources>
        <DataTemplate x:Key="ModuleItemTemplate">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
					<ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <CheckBox Margin="3"
                          VerticalAlignment="Center"
                          HorizontalAlignment="Center"
                          IsChecked="{Binding Selected, Mode=TwoWay}" />
                <TextBlock Margin="5,3"
                           Grid.Column="1"
                           Text="{Binding Name}"
                           Style="{StaticResource ContentTextStyle}" />
                <Rectangle Fill="{StaticResource ColorAccentBrush}" Stroke="{StaticResource ControlBackgroundNormal}" Width="12" Height="12" Grid.Column="2" RadiusX="3" RadiusY="3" ToolTipService.ToolTip="Loaded" Visibility="{Binding Loaded, Converter={StaticResource visibilityConverter}}"/>
                <Rectangle Fill="{StaticResource ControlBackgroundPressedOrange}" Stroke="{StaticResource ControlBackgroundNormal}" Width="12" Height="12" Grid.Column="2" RadiusX="3" RadiusY="3" ToolTipService.ToolTip="Not Loaded" Visibility="{Binding Loaded, Converter={StaticResource invisibilityConverter}}"/>
            </Grid>
        </DataTemplate>
    </UserControl.Resources>

    <Grid VerticalAlignment="Center"
          MinWidth="300"
          MinHeight="200"
          HorizontalAlignment="Center">
    	<i:Interaction.Triggers>
    		<i:EventTrigger>
    			<cal:ActionMessage MethodName="LoadModuleList"/>
    		</i:EventTrigger>
    	</i:Interaction.Triggers>
        <Border BorderBrush="{StaticResource DarkBorder}"
                BorderThickness="1"
                Background="{StaticResource DarkInnerShadowDarkBrush}"
                CornerRadius="2">
            <toolkit:DockPanel LastChildFill="False">
                <TextBlock x:Name="DisplayName"
                           toolkit:DockPanel.Dock="Top"
                           Style="{StaticResource Heading2}"
                           Margin="10" />
                <toolkit:DockPanel toolkit:DockPanel.Dock="Bottom"
                                   Margin="10">
                    <CheckBox x:Name="SaveForNextStart"
                              Content="Save my selection"
                              Margin="0,0,10,0" />
                    <Button x:Name="LoadModules"
                            Content="Load"
                            Width="75"
                            HorizontalAlignment="Right" />
                </toolkit:DockPanel>
            	<Button x:Name="RemoveModules" Content="Unload loaded modules" toolkit:DockPanel.Dock="Bottom" Margin="10,10,10,0" Visibility="{Binding UnloadModulesAvailable, Converter={StaticResource visibilityConverter}}"/>
                <ItemsControl x:Name="Modules"
                              toolkit:DockPanel.Dock="Top"
                              ItemTemplate="{StaticResource ModuleItemTemplate}"
                              Margin="10,0" />
            </toolkit:DockPanel>
        </Border>
        <ctrl:DialogIndicator cal:View.Model="{Binding CurrentBusyViewModel}"
                              d:IsHidden="True" />
        <ctrl:DialogIndicator cal:View.Model="{Binding ActiveDialog}"
                              d:IsHidden="True" />
    </Grid>
</UserControl>
